package com.neuedu.collection.List;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class IteratorDemo {
    public static void main(String[] args) {
        List  list= new ArrayList();
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(4);
        list.add(5);

        for(Iterator  it = list.iterator(); it.hasNext();){
            Object  obj = it.next();
            System.out.println(obj);
            it.remove();

        }
        System.out.println(list.size());
    }
}
